import time
arr1=[int(x) for x in open('m1_sorted.txt')]
arr2=[int(x) for x in open('m2_reverse.txt')]
arr3=[int(x) for x in open('m3_shuffle.txt')]

start = time.perf_counter() 
for i in range(5000-1):
    k=0
    for t in range(5000-1):
        
        if(arr1[t]>arr1[t+1]):
            arr1[t], arr1[t+1]=arr1[t+1], arr1[t]
            k+=1    
    if(k==0):
         break
end = time.perf_counter() 
b = end-start

start = time.perf_counter() 
for i in range(5000-1):
    k=0
    for t in range(5000-1):
        
        if(arr2[t]>arr2[t+1]):
            arr2[t], arr2[t+1]=arr2[t+1], arr2[t]
            k+=1    
    if(k==0):
         break
end = time.perf_counter() 
a = end-start

start = time.perf_counter() 
for i in range(5000-1):
    k=0
    for t in range(5000-1):
        
        if(arr3[t]>arr3[t+1]):
            arr3[t], arr3[t+1]=arr3[t+1], arr3[t]
            k+=1    
    if(k==0):
         break
end = time.perf_counter() 
c = end-start

print(b)
print(a)
print(c) 
